package main.java.cn.wolfcode.config;


import main.java.cn.wolfcode.web.interceptor.CheckLoginInterceptor;
import main.java.cn.wolfcode.web.interceptor.CheckPermissionInterceptor;

/**
 * @author liuquan
 * @program: car-business-springboot
 * @description: 配置类
 * @date 2021-02-18 14:41:39
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    private CheckLoginInterceptor checkLoginInterceptor;
    @Autowired
    private CheckPermissionInterceptor checkPermissionInterceptor;

    public static final String[] EXCLUDE_PATH ={"/index","/appointment/save","/systemDictionaryItem/selectByTypeSn",
            "/empLogin","/login.html","/css/**","/js/**","/img/**"};


    /**
     * 该方法只会运行一次
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        registry.addInterceptor(checkLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);

        registry.addInterceptor(checkPermissionInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);

    }
}
